//检测用户是否登录
if (!localStorage.getItem('big-event-token')) {
	location.href = './login.html'
}
async function getUserInfoFn() {
	const res = await reqGetUserInfo()
	console.log(res)
	const { data: { nickname, user_pic, username } } = res.data
	if (user_pic === null) {
		$('.avatar').css('display', 'inline-block').text(username[0].toUpperCase())
	} else {
		$('.avatar img').css('display', 'inline-block').prop('src', user_pic)
	}
	if (nickname === '') {
		nickname = username
	}
	$('.username').text(nickname)
}
getUserInfoFn()
//退出
$('#logout').on('click', function () {
	layer.confirm('确认退出吗', { icon: 3, title: '提示' }, function () {
		localStorage.removeItem('big-event-token')
		location.href = './login.html'
	})
})
